package com.ruoyi.system.service.estate.emergency.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.SecurityUtils;
import java.util.Date;
import com.ruoyi.system.mapper.estate.emergency.EmergencySuppliesRecordMapper;
import com.ruoyi.system.domain.estate.emergency.EmergencySuppliesRecord;
import com.ruoyi.system.service.estate.emergency.IEmergencySuppliesRecordService;
import com.ruoyi.common.utils.DateUtils;

/**
 * 应急物资出入库记录Service业务层处理
 */
@Service
public class EmergencySuppliesRecordServiceImpl implements IEmergencySuppliesRecordService {
    @Autowired
    private EmergencySuppliesRecordMapper emergencySuppliesRecordMapper;

    /**
     * 查询应急物资出入库记录列表
     * 
     * @param emergencySuppliesRecord 应急物资出入库记录信息
     * @return 应急物资出入库记录集合
     */
    @Override
    public List<EmergencySuppliesRecord> selectEmergencySuppliesRecordList(EmergencySuppliesRecord emergencySuppliesRecord) {
        return emergencySuppliesRecordMapper.selectEmergencySuppliesRecordList(emergencySuppliesRecord);
    }

    /**
     * 查询应急物资出入库记录详细信息
     * 
     * @param recordId 应急物资出入库记录ID
     * @return 应急物资出入库记录信息
     */
    @Override
    public EmergencySuppliesRecord selectEmergencySuppliesRecordById(Long recordId) {
        return emergencySuppliesRecordMapper.selectEmergencySuppliesRecordById(recordId);
    }

    /**
     * 新增应急物资出入库记录
     * 
     * @param emergencySuppliesRecord 应急物资出入库记录信息
     * @return 结果
     */
    @Override
    public int insertEmergencySuppliesRecord(EmergencySuppliesRecord emergencySuppliesRecord) {
        emergencySuppliesRecord.setCreateTime(DateUtils.getNowDate());
        emergencySuppliesRecord.setCreateBy(SecurityUtils.getUsername());
        return emergencySuppliesRecordMapper.insertEmergencySuppliesRecord(emergencySuppliesRecord);
    }

    /**
     * 修改应急物资出入库记录
     * 
     * @param emergencySuppliesRecord 应急物资出入库记录信息
     * @return 结果
     */
    @Override
    public int updateEmergencySuppliesRecord(EmergencySuppliesRecord emergencySuppliesRecord) {
        emergencySuppliesRecord.setUpdateTime(DateUtils.getNowDate());
        emergencySuppliesRecord.setUpdateBy(SecurityUtils.getUsername());
        return emergencySuppliesRecordMapper.updateEmergencySuppliesRecord(emergencySuppliesRecord);
    }

    /**
     * 批量删除应急物资出入库记录
     * 
     * @param recordIds 需要删除的应急物资出入库记录ID
     * @return 结果
     */
    @Override
    public int deleteEmergencySuppliesRecordByIds(Long[] recordIds) {
        return emergencySuppliesRecordMapper.deleteEmergencySuppliesRecordByIds(recordIds);
    }

    /**
     * 删除应急物资出入库记录信息
     * 
     * @param recordId 应急物资出入库记录ID
     * @return 结果
     */
    @Override
    public int deleteEmergencySuppliesRecordById(Long recordId) {
        return emergencySuppliesRecordMapper.deleteEmergencySuppliesRecordById(recordId);
    }

    /**
     * 获取物资分发记录
     * 
     * @return 物资分发记录列表
     */
    @Override
    public List<EmergencySuppliesRecord> selectDistributionRecords() {
        EmergencySuppliesRecord record = new EmergencySuppliesRecord();
        record.setOperationType("1"); // 出库/领用
        return emergencySuppliesRecordMapper.selectEmergencySuppliesRecordList(record);
    }
} 